/**
 * 服务台API
 */

import axios from "./request/http";
// export const outerBaseUrl = `/apiP4`;
export const outerBaseUrl = `http://192.168.8.166:8088/flow`;

export const outerPost = (method, params) => {
  let data = params;
  if (!params instanceof FormData) {
    data = JSON.stringify(params);
  }
  return axios({
    method: "POST",
    url: `${outerBaseUrl}${method}`,
    data
  }).then(res => {
    return Promise.resolve(res.data);
  });
};

export const outerRemove = (method, params) => {
  let data = params;
  if (!params instanceof FormData) {
    data = JSON.stringify(params);
  }
  return axios({
    method: "DELETE",
    url: `${outerBaseUrl}${method}`,
    data
  }).then(res => {
    return Promise.resolve(res.data);
  });
};

export const outeGet = (method, params) => {
  return axios
    .get(`${outerBaseUrl}${method}`, {
      params
    })
    .then(res => {
      return Promise.resolve(res.data);
    });
};

/**
 *
 * @param {*} name 查询模板
 * @returns
 */
export const flowTempGetList = params => {
  return outerPost("/flowTemp/getList", params);
};

export const flowTempInsert = params => {
  return outerPost("/flowTemp/insert", params);
};

export const flowTempEdit = params => {
  return outerPost("/flowTemp/edit", params);
};

export const flowTempDelete = params => {
  return outerRemove("/flowTemp/delete", params);
};

export const flowNodeGetNodeList = params => {
  return outerRemove("/flowNode/getNodeList", params);
};

export const flowNodeInsert = params => {
  return outerRemove("/flowNode/insert", params);
};

export const flowNodeEdit = params => {
  return outerRemove("/flowNode/edit", params);
};
